
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>基础控件使用 · Aivin开发笔记</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Aivin">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-local-video/video-js.min.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../../styles/website.css">
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="android零散知识.html" />
    
    
    <link rel="prev" href="android零散知识.html" />
    

    
        <link rel="shortcut icon" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
        <link rel="bookmark" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    首页
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../doc/常用网站.html">
            
                <a href="../doc/常用网站.html">
            
                    
                    常用网站
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../常用软件/常用软件和框架.html">
            
                <a href="../常用软件/常用软件和框架.html">
            
                    
                    常用软件和框架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../doc/开发规范.html">
            
                <a href="../doc/开发规范.html">
            
                    
                    开发规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../doc/开源软件.html">
            
                <a href="../doc/开源软件.html">
            
                    
                    开源软件和框架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../doc/Android常用代码.html">
            
                <a href="../doc/Android常用代码.html">
            
                    
                    Android常用代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../源码阅读/源码阅读配置.html">
            
                <a href="../源码阅读/源码阅读配置.html">
            
                    
                    源码阅读
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../源码阅读/其他框架源码.html">
            
                <a href="../源码阅读/其他框架源码.html">
            
                    
                    其他框架源码
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../产品经理/产品经理.html">
            
                <a href="../产品经理/产品经理.html">
            
                    
                    产品经理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../设计模式/设计模式.html">
            
                <a href="../设计模式/设计模式.html">
            
                    
                    设计模式
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../设计模式/设计模式.html">
            
                <a href="../设计模式/设计模式.html">
            
                    
                    设计模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../设计模式/模式详解.html">
            
                <a href="../设计模式/模式详解.html">
            
                    
                    模式详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../设计模式/mvc等.html">
            
                <a href="../设计模式/mvc等.html">
            
                    
                    mvc等
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../数据结构/常用数据结构.html">
            
                <a href="../数据结构/常用数据结构.html">
            
                    
                    基本算法
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../数据结构/常用数据结构.html">
            
                <a href="../数据结构/常用数据结构.html">
            
                    
                    常用数据结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../常用算法/算法术语.html">
            
                <a href="../常用算法/算法术语.html">
            
                    
                    算法术语
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../常用算法/排序算法.html">
            
                <a href="../常用算法/排序算法.html">
            
                    
                    排序算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.4" data-path="../常用算法/查找算法.html">
            
                <a href="../常用算法/查找算法.html">
            
                    
                    查找算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.5" data-path="../常用算法/大数相加.html">
            
                <a href="../常用算法/大数相加.html">
            
                    
                    大数相加
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.6" data-path="../常用算法/集合的所有子集.html">
            
                <a href="../常用算法/集合的所有子集.html">
            
                    
                    获得集合的所有子集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.7" data-path="../常用算法/扫描线种子填充算法.html">
            
                <a href="../常用算法/扫描线种子填充算法.html">
            
                    
                    扫描线种子填充算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.8" data-path="../常用算法/其他算法.html">
            
                <a href="../常用算法/其他算法.html">
            
                    
                    其他算法
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../java基础/原码补码反码.html">
            
                <a href="../java基础/原码补码反码.html">
            
                    
                    Java部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../java基础/原码补码反码.html">
            
                <a href="../java基础/原码补码反码.html">
            
                    
                    原码补码反码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../java基础/java常用代码.html">
            
                <a href="../java基础/java常用代码.html">
            
                    
                    java常用代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.3" data-path="../java基础/JVM详解.html">
            
                <a href="../java基础/JVM详解.html">
            
                    
                    JVM详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.4" data-path="../java基础/类加载机制.html">
            
                <a href="../java基础/类加载机制.html">
            
                    
                    类加载机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.5" data-path="../java基础/内存模型.html">
            
                <a href="../java基础/内存模型.html">
            
                    
                    内存模型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.6" data-path="../java基础/GC机制.html">
            
                <a href="../java基础/GC机制.html">
            
                    
                    GC机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.7" data-path="../java基础/对象内存布局.html">
            
                <a href="../java基础/对象内存布局.html">
            
                    
                    对象内存布局
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.8" data-path="../java基础/继承多态.html">
            
                <a href="../java基础/继承多态.html">
            
                    
                    继承和多态
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.9" data-path="../java基础/相等判断.html">
            
                <a href="../java基础/相等判断.html">
            
                    
                    相等判断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.10" data-path="../java基础/Java容器类.html">
            
                <a href="../java基础/Java容器类.html">
            
                    
                    Java容器类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.11" data-path="../java基础/Java枚举.html">
            
                <a href="../java基础/Java枚举.html">
            
                    
                    Java枚举
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.12" data-path="../java基础/自定义异常.html">
            
                <a href="../java基础/自定义异常.html">
            
                    
                    自定义异常
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.13" data-path="../java基础/深度拷贝.html">
            
                <a href="../java基础/深度拷贝.html">
            
                    
                    深度拷贝
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.14" data-path="../java基础/泛型详解.html">
            
                <a href="../java基础/泛型详解.html">
            
                    
                    泛型详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.15" data-path="../java基础/线程详解.html">
            
                <a href="../java基础/线程详解.html">
            
                    
                    线程详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.16" data-path="../java基础/java注解.html">
            
                <a href="../java基础/java注解.html">
            
                    
                    注解详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.17" data-path="../java基础/数据解析.html">
            
                <a href="../java基础/数据解析.html">
            
                    
                    数据解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.18" data-path="../java基础/java8新特性.html">
            
                <a href="../java基础/java8新特性.html">
            
                    
                    Java8新特性
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="android零散知识.html">
            
                <a href="android零散知识.html">
            
                    
                    Android部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.12.1" data-path="基础控件使用.html">
            
                <a href="基础控件使用.html">
            
                    
                    基础控件使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="android零散知识.html">
            
                <a href="android零散知识.html">
            
                    
                    Android零散知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.3" data-path="android坐标体系.html">
            
                <a href="android坐标体系.html">
            
                    
                    Android坐标体系
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.4" data-path="APP的启动流程.html">
            
                <a href="APP的启动流程.html">
            
                    
                    APP启动流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.5" data-path="View加载流程.html">
            
                <a href="View加载流程.html">
            
                    
                    View加载流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.6" data-path="事件分发机制.html">
            
                <a href="事件分发机制.html">
            
                    
                    事件分发机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.7" data-path="控件绘制流程.html">
            
                <a href="控件绘制流程.html">
            
                    
                    控件绘制流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.8" data-path="常用shape.html">
            
                <a href="常用shape.html">
            
                    
                    常用shape
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.9" data-path="进程通信.html">
            
                <a href="进程通信.html">
            
                    
                    进程通信
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.10" data-path="../通信方式/通信方式详解.html">
            
                <a href="../通信方式/通信方式详解.html">
            
                    
                    通信方式详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.11" data-path="Binder详解.html">
            
                <a href="Binder详解.html">
            
                    
                    Binder详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.12" data-path="Handler详解.html">
            
                <a href="Handler详解.html">
            
                    
                    Handle详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.13" data-path="Fragment详解.html">
            
                <a href="Fragment详解.html">
            
                    
                    Fragment详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.14" data-path="Activity详解.html">
            
                <a href="Activity详解.html">
            
                    
                    Activity详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.15" data-path="BroadcastReceiver.html">
            
                <a href="BroadcastReceiver.html">
            
                    
                    BroadcastReceiver详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.16" data-path="Service服务.html">
            
                <a href="Service服务.html">
            
                    
                    Service详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.17" data-path="动画详解.html">
            
                <a href="动画详解.html">
            
                    
                    动画详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.18" data-path="屏幕刷新机制.html">
            
                <a href="屏幕刷新机制.html">
            
                    
                    屏幕刷新机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.19" data-path="屏幕适配.html">
            
                <a href="屏幕适配.html">
            
                    
                    屏幕适配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.20" data-path="图片加载详解.html">
            
                <a href="图片加载详解.html">
            
                    
                    图片加载详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.21" data-path="WebView详解.html">
            
                <a href="WebView详解.html">
            
                    
                    WebView详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.22" data-path="沉浸式.html">
            
                <a href="沉浸式.html">
            
                    
                    沉浸式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.23" data-path="相机模块.html">
            
                <a href="相机模块.html">
            
                    
                    相机模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.24" data-path="地图模块.html">
            
                <a href="地图模块.html">
            
                    
                    地图模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.25" data-path="Androidstudio插件开发.html">
            
                <a href="Androidstudio插件开发.html">
            
                    
                    Androidstudio插件开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.26" data-path="Apk插件化开发.html">
            
                <a href="Apk插件化开发.html">
            
                    
                    Apk插件化开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.27" data-path="App组件化开发.html">
            
                <a href="App组件化开发.html">
            
                    
                    App组件化开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.28" data-path="sdk开发.html">
            
                <a href="sdk开发.html">
            
                    
                    sdk开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.29" data-path="APP优化.html">
            
                <a href="APP优化.html">
            
                    
                    APP优化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.30" data-path="项目参数配置.html">
            
                <a href="项目参数配置.html">
            
                    
                    项目参数配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.31" data-path="App发布.html">
            
                <a href="App发布.html">
            
                    
                    App发布
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.32" data-path="Android外挂.html">
            
                <a href="Android外挂.html">
            
                    
                    Android外挂
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.33" data-path="Android字节码插桩.html">
            
                <a href="Android字节码插桩.html">
            
                    
                    Android字节码插桩
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.34" data-path="智能家居.html">
            
                <a href="智能家居.html">
            
                    
                    智能家居
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../python/python基础.html">
            
                <a href="../python/python基础.html">
            
                    
                    python部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../python/python基础.html">
            
                <a href="../python/python基础.html">
            
                    
                    python基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" data-path="../python/python爬虫.html">
            
                <a href="../python/python爬虫.html">
            
                    
                    python爬虫
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../gradle/Groovy.html">
            
                <a href="../gradle/Groovy.html">
            
                    
                    Groovy
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../kotlin/kotlin部分.html">
            
                <a href="../kotlin/kotlin部分.html">
            
                    
                    kotlin部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="../flutter/flutter部分.html">
            
                <a href="../flutter/flutter部分.html">
            
                    
                    flutter部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="../native/ccpp.html">
            
                <a href="../native/ccpp.html">
            
                    
                    native部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.17.1" data-path="../native/Linux.html">
            
                <a href="../native/Linux.html">
            
                    
                    Linux
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.2" data-path="../native/ccpp.html">
            
                <a href="../native/ccpp.html">
            
                    
                    cCpp
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.3" data-path="../native/NDK.html">
            
                <a href="../native/NDK.html">
            
                    
                    NDK
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.4" data-path="../native/系统编译剪裁.html">
            
                <a href="../native/系统编译剪裁.html">
            
                    
                    系统编译剪裁
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.5" data-path="../native/音视频.html">
            
                <a href="../native/音视频.html">
            
                    
                    音视频
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.6" data-path="../native/音视频第三方库.html">
            
                <a href="../native/音视频第三方库.html">
            
                    
                    音视频第三方库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.7" data-path="../native/相关代码.html">
            
                <a href="../native/相关代码.html">
            
                    
                    相关代码
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="../server/服务器部分.html">
            
                <a href="../server/服务器部分.html">
            
                    
                    服务器部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="../webDev/web部分.html">
            
                <a href="../webDev/web部分.html">
            
                    
                    web部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20" data-path="../人工智能/人工智能相关概念.html">
            
                <a href="../人工智能/人工智能相关概念.html">
            
                    
                    人工智能
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21" data-path="../面试真题/极飞.html">
            
                <a href="../面试真题/极飞.html">
            
                    
                    面试真题
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >基础控件使用</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#application"><b>1. </b>Application</a></li><li><span class="title-icon "></span><a href="#edittext"><b>2. </b>EditText</a></li><ul><li><span class="title-icon "></span><a href="#edittext-&#x9ED8;&#x8BA4;&#x4E0D;&#x83B7;&#x53D6;&#x7126;&#x70B9;"><b>2.1. </b>EditText &#x9ED8;&#x8BA4;&#x4E0D;&#x83B7;&#x53D6;&#x7126;&#x70B9;</a></li><li><span class="title-icon "></span><a href="#edittext-&#x6309;&#x4E0B;&#x56DE;&#x8F66;&#x952E;&#x9690;&#x85CF;&#x5149;&#x6807;-&#x548C;&#x6536;&#x8D77;&#x952E;&#x76D8;"><b>2.2. </b>EditText &#x6309;&#x4E0B;&#x56DE;&#x8F66;&#x952E;&#x9690;&#x85CF;&#x5149;&#x6807; &#x548C;&#x6536;&#x8D77;&#x952E;&#x76D8;</a></li></ul><li><span class="title-icon "></span><a href="#textview"><b>3. </b>TextView</a></li><ul><li><span class="title-icon "></span><a href="#drawablepadding"><b>3.1. </b>drawablePadding</a></li><li><span class="title-icon "></span><a href="#drawable-&#x548C;&#x6587;&#x5B57;&#x90FD;&#x5C45;&#x4E2D;"><b>3.2. </b>drawable &#x548C;&#x6587;&#x5B57;&#x90FD;&#x5C45;&#x4E2D;</a></li></ul><li><span class="title-icon "></span><a href="#popupwindow"><b>4. </b>PopupWindow</a></li><ul><li><span class="title-icon "></span><a href="#popupwindow-&#x8BBE;&#x7F6E;&#x5BBD;&#x9AD8;"><b>4.1. </b>PopupWindow &#x8BBE;&#x7F6E;&#x5BBD;&#x9AD8;</a></li><li><span class="title-icon "></span><a href="#popupwindow-&#x534A;&#x900F;&#x660E;"><b>4.2. </b>PopupWindow &#x534A;&#x900F;&#x660E;</a></li><li><span class="title-icon "></span><a href="#&#x900F;&#x660E;&#x5EA6;&#x5BF9;&#x7167;&#x8868;"><b>4.3. </b>&#x900F;&#x660E;&#x5EA6;&#x5BF9;&#x7167;&#x8868;</a></li><li><span class="title-icon "></span><a href="#&#x900F;&#x660E;&#x5EA6;&#x5BF9;&#x7167;&#x8868;&#x5B8C;&#x6574;&#x7248;"><b>4.4. </b>&#x900F;&#x660E;&#x5EA6;&#x5BF9;&#x7167;&#x8868;(&#x5B8C;&#x6574;&#x7248;)</a></li><li><span class="title-icon "></span><a href="#&#x900F;&#x660E;&#x5EA6;&#x767E;&#x5206;&#x6BD4;&#x8F6C;&#x6362;&#x6210;&#x5341;&#x516D;&#x8FDB;&#x5236;"><b>4.5. </b>&#x900F;&#x660E;&#x5EA6;&#x767E;&#x5206;&#x6BD4;&#x8F6C;&#x6362;&#x6210;&#x5341;&#x516D;&#x8FDB;&#x5236;</a></li><li><span class="title-icon "></span><a href="#popupwindow-&#x91CC;&#x89E6;&#x53D1;&#x5F39;&#x7A97;--&#x4E8C;&#x7EA7;&#x5F39;&#x7A97;"><b>4.6. </b>PopupWindow &#x91CC;&#x89E6;&#x53D1;&#x5F39;&#x7A97; , &#x4E8C;&#x7EA7;&#x5F39;&#x7A97;</a></li><li><span class="title-icon "></span><a href="#popupwindow-&#x89E6;&#x78B0;&#x5916;&#x8FB9;&#x5173;&#x95ED;"><b>4.7. </b>PopupWindow &#x89E6;&#x78B0;&#x5916;&#x8FB9;&#x5173;&#x95ED;</a></li><li><span class="title-icon "></span><a href="#popupwindow-&#x83B7;&#x53D6;-showatlocation-&#x7684;-parent"><b>4.8. </b>PopupWindow &#x83B7;&#x53D6; showAtLocation &#x7684; parent</a></li><li><span class="title-icon "></span><a href="#popupwindow-&#x5185;&#x90E8;&#x8FDB;&#x884C;&#x89C6;&#x56FE;&#x5207;&#x6362;"><b>4.9. </b>PopupWindow &#x5185;&#x90E8;&#x8FDB;&#x884C;&#x89C6;&#x56FE;&#x5207;&#x6362;</a></li></ul><li><span class="title-icon "></span><a href="#sharedpreferences"><b>5. </b>SharedPreferences</a></li><ul><li><span class="title-icon "></span><a href="#sharedpreferences--apply-&#x548C;--commit-&#x7684;&#x533A;&#x522B;"><b>5.1. </b>SharedPreferences  apply &#x548C;  commit &#x7684;&#x533A;&#x522B;</a></li><li><span class="title-icon "></span><a href="#sharedpreferences---&#x662F;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;&#x7684;&#x5417;"><b>5.2. </b>SharedPreferences   &#x662F;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;&#x7684;&#x5417;</a></li><li><span class="title-icon "></span><a href="#sharedpreferences-&#x662F;&#x8FDB;&#x7A0B;&#x5B89;&#x5168;&#x7684;&#x5417;&#xFF1F;-&#x5982;&#x4F55;&#x4FDD;&#x8BC1;&#x8FDB;&#x7A0B;&#x5B89;&#x5168;"><b>5.3. </b>SharedPreferences &#x662F;&#x8FDB;&#x7A0B;&#x5B89;&#x5168;&#x7684;&#x5417;&#xFF1F; &#x5982;&#x4F55;&#x4FDD;&#x8BC1;&#x8FDB;&#x7A0B;&#x5B89;&#x5168;</a></li></ul><li><span class="title-icon "></span><a href="#alertdialog-&#x6309;&#x94AE;&#x5927;&#x5C0F;&#x95EE;&#x9898;"><b>6. </b>AlertDialog &#x6309;&#x94AE;&#x5927;&#x5C0F;&#x95EE;&#x9898;</a></li><li><span class="title-icon "></span><a href="#dialog-&#x5168;&#x5C4F;&#x663E;&#x793A;"><b>7. </b>Dialog &#x5168;&#x5C4F;&#x663E;&#x793A;</a></li><li><span class="title-icon "></span><a href="#seekbar"><b>8. </b>SeekBar</a></li><ul><li><span class="title-icon "></span><a href="#seekbar-&#x8FDB;&#x5EA6;&#x6761;&#x663E;&#x793A;&#x4E0D;&#x5168;&#x3001;&#x663E;&#x793A;&#x4E0D;&#x9876;&#x683C;&#x7684;&#x95EE;&#x9898;"><b>8.1. </b>SeekBar &#x8FDB;&#x5EA6;&#x6761;&#x663E;&#x793A;&#x4E0D;&#x5168;&#x3001;&#x663E;&#x793A;&#x4E0D;&#x9876;&#x683C;&#x7684;&#x95EE;&#x9898;</a></li><li><span class="title-icon "></span><a href="#&#x70B9;&#x51FB;&#x6216;&#x62D6;&#x52A8;&#x7684;&#x5206;&#x6BB5;&#x8FDB;&#x5EA6;&#x6761;"><b>8.2. </b>&#x70B9;&#x51FB;&#x6216;&#x62D6;&#x52A8;&#x7684;&#x5206;&#x6BB5;&#x8FDB;&#x5EA6;&#x6761;</a></li><li><span class="title-icon "></span><a href="#clipdrawable-&#x5B9E;&#x73B0;&#x56FE;&#x7247;&#x8FDB;&#x5EA6;&#x6761;-&#x6548;&#x679C;"><b>8.3. </b>ClipDrawable &#x5B9E;&#x73B0;&#x56FE;&#x7247;&#x8FDB;&#x5EA6;&#x6761; &#x6548;&#x679C;</a></li><li><span class="title-icon "></span><a href="#&#x52A8;&#x6001;&#x6761;&#x7EB9;&#x80CC;&#x666F;&#x8FDB;&#x5EA6;&#x6761;"><b>8.4. </b>&#x52A8;&#x6001;&#x6761;&#x7EB9;&#x80CC;&#x666F;&#x8FDB;&#x5EA6;&#x6761;</a></li></ul><li><span class="title-icon "></span><a href="#listview-&#x52A8;&#x6001;&#x6539;&#x53D8;&#x9AD8;&#x5EA6;"><b>9. </b>ListView &#x52A8;&#x6001;&#x6539;&#x53D8;&#x9AD8;&#x5EA6;</a></li><li><span class="title-icon "></span><a href="#&#x7EA6;&#x675F;&#x5E03;&#x5C40;-constraintlayout"><b>10. </b>&#x7EA6;&#x675F;&#x5E03;&#x5C40; ConstraintLayout</a></li><ul><li><span class="title-icon "></span><a href="#constraintlayout-&#x5E38;&#x7528;&#x5C5E;&#x6027;"><b>10.1. </b>ConstraintLayout &#x5E38;&#x7528;&#x5C5E;&#x6027;</a></li></ul></ul></div><a href="#application" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="application"><a name="application" class="anchor-navigation-ex-anchor" href="#application"><i class="fa fa-link" aria-hidden="true"></i></a>1. Application</h1>
<pre><code class="lang-text">// Application &#x4E2D;&#x663E;&#x793A; Dialog (AlertDialog) 
&#x501F;&#x52A9; ActivityLifecycleCallbacks &#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#x56DE;&#x8C03; &#x83B7;&#x5F97; Context
new AlertDialog.Builder(mContext);   

// &#x901A;&#x8FC7; Application  &#x4F20;&#x503C; &#x7F3A;&#x70B9;
</code></pre>
<h1 id="edittext"><a name="edittext" class="anchor-navigation-ex-anchor" href="#edittext"><i class="fa fa-link" aria-hidden="true"></i></a>2. EditText</h1>
<h2 id="edittext-&#x9ED8;&#x8BA4;&#x4E0D;&#x83B7;&#x53D6;&#x7126;&#x70B9;"><a name="edittext-&#x9ED8;&#x8BA4;&#x4E0D;&#x83B7;&#x53D6;&#x7126;&#x70B9;" class="anchor-navigation-ex-anchor" href="#edittext-&#x9ED8;&#x8BA4;&#x4E0D;&#x83B7;&#x53D6;&#x7126;&#x70B9;"><i class="fa fa-link" aria-hidden="true"></i></a>2.1. EditText &#x9ED8;&#x8BA4;&#x4E0D;&#x83B7;&#x53D6;&#x7126;&#x70B9;</h2>
<pre><code class="lang-text">1&#x3001;&#x89E3;&#x51B3; &#x5728; PopupWindow &#x4E2D; &#xFF0C;EditText &#x6709;&#x65F6;&#x65E0;&#x6CD5;&#x83B7;&#x53D6;&#x8F93;&#x5165;&#x6CD5;&#x7126;&#x70B9;&#x3002;
&#x5728; PopupWindow &#x4E2D;&#x8BBE;&#x7F6E;&#x4E00;&#x4E0B;  this.setFocusable(true);

2&#x3001;&#x8BA9; EditText &#x9ED8;&#x8BA4;&#x4E0D;&#x83B7;&#x53D6;&#x7126;&#x70B9;
&#x5728; EditText &#x7684;&#x7236;&#x5BB9;&#x5668;&#x4E2D;&#x52A0;&#x5165;&#x4EE5;&#x4E0B;&#x4E24;&#x4E2A;&#x914D;&#x7F6E;&#xFF0C;&#x8BA9;&#x5176;&#x62A2;&#x593A;&#x5230;&#x7126;&#x70B9;&#x3002;
android:focusableInTouchMode=&quot;true&quot;
android:focusable=&quot;true&quot;
</code></pre>
<h2 id="edittext-&#x6309;&#x4E0B;&#x56DE;&#x8F66;&#x952E;&#x9690;&#x85CF;&#x5149;&#x6807;-&#x548C;&#x6536;&#x8D77;&#x952E;&#x76D8;"><a name="edittext-&#x6309;&#x4E0B;&#x56DE;&#x8F66;&#x952E;&#x9690;&#x85CF;&#x5149;&#x6807;-&#x548C;&#x6536;&#x8D77;&#x952E;&#x76D8;" class="anchor-navigation-ex-anchor" href="#edittext-&#x6309;&#x4E0B;&#x56DE;&#x8F66;&#x952E;&#x9690;&#x85CF;&#x5149;&#x6807;-&#x548C;&#x6536;&#x8D77;&#x952E;&#x76D8;"><i class="fa fa-link" aria-hidden="true"></i></a>2.2. EditText &#x6309;&#x4E0B;&#x56DE;&#x8F66;&#x952E;&#x9690;&#x85CF;&#x5149;&#x6807; &#x548C;&#x6536;&#x8D77;&#x952E;&#x76D8;</h2>
<pre><code class="lang-text">private void closeInputMethod(EditText theEditText) {
    theEditText.setCursorVisible(false); //&#x5173;&#x95ED;&#x5149;&#x6807;
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    boolean isOpen = imm.isActive();
    if (isOpen) {
        imm.hideSoftInputFromWindow(theEditText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    }
}
</code></pre>
<h1 id="textview"><a name="textview" class="anchor-navigation-ex-anchor" href="#textview"><i class="fa fa-link" aria-hidden="true"></i></a>3. TextView</h1>
<h2 id="drawablepadding"><a name="drawablepadding" class="anchor-navigation-ex-anchor" href="#drawablepadding"><i class="fa fa-link" aria-hidden="true"></i></a>3.1. drawablePadding</h2>
<pre><code class="lang-text">// &#x5728; xml &#x4E2D;&#x914D;&#x7F6E;
&lt;TextView
    android:drawableStart=&quot;@mipmap/icon_itemvideo_normal&quot;
    android:drawablePadding=&quot;20dp&quot;
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;match_parent&quot; /&gt;

// &#x7528;&#x4EE3;&#x7801;&#x914D;&#x7F6E;    
private void setDrawable(TextView textView ,int drawableId){
    Drawable drawable= mContext.getResources().getDrawable(drawableId);
    drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
    textView.setCompoundDrawables(drawable,null,null,null);
}
</code></pre>
<h2 id="drawable-&#x548C;&#x6587;&#x5B57;&#x90FD;&#x5C45;&#x4E2D;"><a name="drawable-&#x548C;&#x6587;&#x5B57;&#x90FD;&#x5C45;&#x4E2D;" class="anchor-navigation-ex-anchor" href="#drawable-&#x548C;&#x6587;&#x5B57;&#x90FD;&#x5C45;&#x4E2D;"><i class="fa fa-link" aria-hidden="true"></i></a>3.2. drawable &#x548C;&#x6587;&#x5B57;&#x90FD;&#x5C45;&#x4E2D;</h2>
<pre><code class="lang-text">/**
&lt;com.example.unlockview.HXDrawableCenterTextView
    android:layout_width=&quot;300dp&quot;
    android:layout_height=&quot;100dp&quot;
    android:background=&quot;@drawable/dispatch_round_corner_btn_green&quot;
    android:drawableLeft=&quot;@mipmap/icon_create_add&quot;
    android:drawablePadding=&quot;30dp&quot;
    android:gravity=&quot;start|center_vertical&quot;
    android:text=&quot;&#x6DFB;&#x52A0;&quot;
    android:textColor=&quot;@color/white&quot; /&gt;

 &#x6CE8;&#x610F; android:gravity &#x7684;&#x8BBE;&#x7F6E;&#xFF0C;&#x8981; start
 */
public class HXDrawableCenterTextView extends AppCompatTextView {

    public HXDrawableCenterTextView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
    }


    @Override
    protected void onDraw(Canvas canvas) {
        translateView(canvas);
        super.onDraw(canvas);
    }

    private void translateView(Canvas canvas){
        Drawable[] drawables = getCompoundDrawables();
        if(drawables==null){
            return;
        }

        Drawable drawableLeft = drawables[0]; // &#x8FD9;&#x91CC;&#x8981;&#x6839;&#x636E; drawableTop &#x8FD8;&#x662F;&#x5176;&#x4ED6;&#x6765;&#x4FEE;&#x6539;
        if(drawableLeft==null){
            return;
        }

        float textWidth = getPaint().measureText(getText().toString());
        int drawablePadding = getCompoundDrawablePadding();
        int drawableWidth = drawableLeft.getIntrinsicWidth();
        float bodyWidth = textWidth + drawableWidth + drawablePadding;
        canvas.translate((getWidth() - bodyWidth) /2,0);
    }
}
</code></pre>
<h1 id="popupwindow"><a name="popupwindow" class="anchor-navigation-ex-anchor" href="#popupwindow"><i class="fa fa-link" aria-hidden="true"></i></a>4. PopupWindow</h1>
<h2 id="popupwindow-&#x8BBE;&#x7F6E;&#x5BBD;&#x9AD8;"><a name="popupwindow-&#x8BBE;&#x7F6E;&#x5BBD;&#x9AD8;" class="anchor-navigation-ex-anchor" href="#popupwindow-&#x8BBE;&#x7F6E;&#x5BBD;&#x9AD8;"><i class="fa fa-link" aria-hidden="true"></i></a>4.1. PopupWindow &#x8BBE;&#x7F6E;&#x5BBD;&#x9AD8;</h2>
<p><a href="https://gitee.com/hnyer/PopuwindowDemo" target="_blank">https://gitee.com/hnyer/PopuwindowDemo</a></p>
<pre><code class="lang-text">1&#x3001;PopupWindow  &#x5728; xml &#x4E2D;&#x8BBE;&#x7F6E;&#x5BBD;&#x9AD8;&#x65E0;&#x6548;&#x7684;&#x539F;&#x56E0;&#x548C;&#x89E3;&#x51B3;&#x65B9;&#x6848;&#xFF1A;
PopupWindow &#x6CA1;&#x6709;&#x7EE7;&#x627F; Viewgroup &#xFF0C;&#x56E0;&#x6B64;&#x6700;&#x5916;&#x5C42;&#x5E03;&#x5C40;&#x5C5E;&#x6027;&#x7684;&#x5BBD;&#x9AD8;&#x65E0;&#x6548;&#xFF0C;
&#x89E3;&#x51B3;&#x65B9;&#x6CD5;&#x662F;&#xFF1A;
1&#x3001;&#x5728;&#x5728;xml&#x4E2D;&#x5957;&#x4E24;&#x5C42;&#xFF0C;&#x7B2C;&#x4E8C;&#x5C42;&#x6307;&#x5B9A;&#x957F;&#x5BBD;&#x3002; (&#x7B2C;&#x4E00;&#x5C42;&#x5176;&#x5B9E;&#x5C31;&#x76F8;&#x5F53;&#x4E8E;&#x6DFB;&#x52A0;&#x4E86;&#x4E00;&#x4E2A; Viewgroup )
3&#x3001;&#x6216;&#x8005;&#x5728;&#x4EE3;&#x7801;&#x4E2D;&#x52A0;&#x4E00;&#x4E2A; Viewgroup &#x5C31;&#x884C;&#x4E86;
2&#x3001;&#x6216;&#x8005;&#x5728;&#x4EE3;&#x7801;&#x4E2D;&#x8BBE;&#x7F6E;&#x5177;&#x4F53;&#x5BBD;&#x9AD8;&#x3002;

public View  initView( Context context ) {
    LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout linearLayout = new LinearLayout(context);
    View rootView  = inflater.inflate(R.layout.oofaywindow, linearLayout);
    return rootView ;
}

PopupWindow + ViewPager + fragment &#x7684;&#x7EC4;&#x5408;&#x4F1A;&#x51FA;&#x73B0;&#x95EE;&#x9898; No view found for id 0xxxxxxxxx
&#x53EF;&#x4EE5;&#x91C7;&#x7528; DialogFragment + ViewPager + fragment &#x7EC4;&#x5408;
https://gitee.com/Aivin_CodeShare/android_tool_code/raw/master/precheck2.zip
</code></pre>
<h2 id="popupwindow-&#x534A;&#x900F;&#x660E;"><a name="popupwindow-&#x534A;&#x900F;&#x660E;" class="anchor-navigation-ex-anchor" href="#popupwindow-&#x534A;&#x900F;&#x660E;"><i class="fa fa-link" aria-hidden="true"></i></a>4.2. PopupWindow &#x534A;&#x900F;&#x660E;</h2>
<pre><code class="lang-text">&#x65B9;&#x6848;&#x6709;&#x4E24;&#x4E2A;
1&#x3001;&#x65B9;&#x6848;1
void setWindowFilter(float alpha ,Activity activity) {
    WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
    lp.alpha = alpha;
    lp.dimAmount = alpha;
    activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    activity.getWindow().setAttributes(lp);
}

setOnDismissListener(new OnDismissListener() {
            @Override
            public void onDismiss() {
                setWindowFilter(1f , (Activity) context);
            }
        });

@Override
public void showAtLocation(View parent, int gravity, int x, int y) {
    setWindowFilter(alpha , (Activity) context);
    super.showAtLocation(parent, gravity, x, y);
}

2&#x3001;&#x65B9;&#x6848;2
android:background=&quot;#XXxxxxxx&quot;
&#x8BF4;&#x660E;&#xFF1A;&#x534A;&#x900F;&#x660E;&#x989C;&#x8272;&#x503C;&#x5171;8&#x4F4D;&#xFF0C;&#x524D;2&#x4F4D;&#x662F;&#x900F;&#x660E;&#x5EA6;&#xFF0C;&#x540E;6&#x4F4D;&#x662F;&#x989C;&#x8272;&#x3002;
&#x5168;&#x900F;&#x660E;&#xFF1A;#00000000
&#x534A;&#x900F;&#x660E;&#xFF1A;#80000000
&#x4E0D;&#x900F;&#x660E;&#xFF1A;#FF000000
&#x767D;&#x8272;&#x534A;&#x900F;&#x660E;&#xFF1A;#80FFFFFF
&#x7EA2;&#x8272;30%&#x900F;&#x660E;&#xFF1A;#4Dca0d0d
</code></pre>
<h2 id="&#x900F;&#x660E;&#x5EA6;&#x5BF9;&#x7167;&#x8868;"><a name="&#x900F;&#x660E;&#x5EA6;&#x5BF9;&#x7167;&#x8868;" class="anchor-navigation-ex-anchor" href="#&#x900F;&#x660E;&#x5EA6;&#x5BF9;&#x7167;&#x8868;"><i class="fa fa-link" aria-hidden="true"></i></a>4.3. &#x900F;&#x660E;&#x5EA6;&#x5BF9;&#x7167;&#x8868;</h2>
<table>
<thead>
<tr>
<th>&#x900F;&#x660E;&#x5EA6;</th>
<th>&#x767E;&#x5206;&#x6BD4;</th>
<th>&#x6570;&#x503C;</th>
</tr>
</thead>
<tbody>
<tr>
<td>&#x4E0D;&#x900F;&#x660E;</td>
<td>100%</td>
<td>FF</td>
</tr>
<tr>
<td></td>
<td>95%</td>
<td>F2</td>
</tr>
<tr>
<td></td>
<td>90%</td>
<td>E6</td>
</tr>
<tr>
<td></td>
<td>85%</td>
<td>D9</td>
</tr>
<tr>
<td></td>
<td>80%</td>
<td>CC</td>
</tr>
<tr>
<td></td>
<td>75%</td>
<td>BF</td>
</tr>
<tr>
<td></td>
<td>70%</td>
<td>B3</td>
</tr>
<tr>
<td></td>
<td>65%</td>
<td>A6</td>
</tr>
<tr>
<td></td>
<td>60%</td>
<td>99</td>
</tr>
<tr>
<td></td>
<td>55%</td>
<td>8C</td>
</tr>
<tr>
<td>&#x534A;&#x900F;&#x660E;</td>
<td>50%</td>
<td>80</td>
</tr>
<tr>
<td></td>
<td>45%</td>
<td>73</td>
</tr>
<tr>
<td></td>
<td>40%</td>
<td>66</td>
</tr>
<tr>
<td></td>
<td>35%</td>
<td>59</td>
</tr>
<tr>
<td></td>
<td>30%</td>
<td>4D</td>
</tr>
<tr>
<td></td>
<td>25%</td>
<td>40</td>
</tr>
<tr>
<td></td>
<td>20%</td>
<td>33</td>
</tr>
<tr>
<td></td>
<td>15%</td>
<td>26</td>
</tr>
<tr>
<td></td>
<td>10%</td>
<td>1A</td>
</tr>
<tr>
<td></td>
<td>5%</td>
<td>0D</td>
</tr>
<tr>
<td>&#x5168;&#x900F;&#x660E;</td>
<td>0%</td>
<td>00</td>
</tr>
</tbody>
</table>
<h2 id="&#x900F;&#x660E;&#x5EA6;&#x5BF9;&#x7167;&#x8868;&#x5B8C;&#x6574;&#x7248;"><a name="&#x900F;&#x660E;&#x5EA6;&#x5BF9;&#x7167;&#x8868;&#x5B8C;&#x6574;&#x7248;" class="anchor-navigation-ex-anchor" href="#&#x900F;&#x660E;&#x5EA6;&#x5BF9;&#x7167;&#x8868;&#x5B8C;&#x6574;&#x7248;"><i class="fa fa-link" aria-hidden="true"></i></a>4.4. &#x900F;&#x660E;&#x5EA6;&#x5BF9;&#x7167;&#x8868;(&#x5B8C;&#x6574;&#x7248;)</h2>
<pre><code class="lang-text">100% &#x2014; FF    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=255
99% &#x2014; FC    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=252
98% &#x2014; FA    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=250
97% &#x2014; F7    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=247
96% &#x2014; F5    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=245
95% &#x2014; F2    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=242
94% &#x2014; F0    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=240
93% &#x2014; ED    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=237
92% &#x2014; EB    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=235
91% &#x2014; E8    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=232
90% &#x2014; E6    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=230
89% &#x2014; E3    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=227
88% &#x2014; E0    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=224
87% &#x2014; DE    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=222
86% &#x2014; DB    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=219
85% &#x2014; D9    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=217
84% &#x2014; D6    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=214
83% &#x2014; D4    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=212
82% &#x2014; D1    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=209
81% &#x2014; CF    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=207
80% &#x2014; CC    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=204
79% &#x2014; C9    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=201
78% &#x2014; C7    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=199
77% &#x2014; C4    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=196
76% &#x2014; C2    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=194
75% &#x2014; BF    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=191
74% &#x2014; BD    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=189
73% &#x2014; BA    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=186
72% &#x2014; B8    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=184
71% &#x2014; B5    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=181
70% &#x2014; B3    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=179
69% &#x2014; B0    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=176
68% &#x2014; AD    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=173
67% &#x2014; AB    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=171
66% &#x2014; A8    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=168
65% &#x2014; A6    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=166
64% &#x2014; A3    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=163
63% &#x2014; A1    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=161
62% &#x2014; 9E    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=158
61% &#x2014; 9C    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=156
60% &#x2014; 99    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=153
58% &#x2014; 96    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=150
58% &#x2014; 94    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=148
57% &#x2014; 91    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=145
56% &#x2014; 8F    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=143
55% &#x2014; 8C    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=140
54% &#x2014; 8A    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=138
52% &#x2014; 87    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=135
52% &#x2014; 85    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=133
51% &#x2014; 82    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=130
50% &#x2014; 80    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=128
49% &#x2014; 7D    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=125
48% &#x2014; 7A    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=122
47% &#x2014; 78    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=120
46% &#x2014; 75    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=117
45% &#x2014; 73    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=115
44% &#x2014; 70    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=112
43% &#x2014; 6E    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=110
42% &#x2014; 6B    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=107
41% &#x2014; 69    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=105
40% &#x2014; 66    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=102
39% &#x2014; 63    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=99
38% &#x2014; 61    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=97
37% &#x2014; 5E    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=94
36% &#x2014; 5C    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=92
35% &#x2014; 59    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=89
34% &#x2014; 57    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=87
33% &#x2014; 54    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=84
32% &#x2014; 52    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=82
31% &#x2014; 4F    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=79
30% &#x2014; 4D    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=77
29% &#x2014; 4A    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=74
28% &#x2014; 47    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=71
27% &#x2014; 45    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=69
26% &#x2014; 42    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=66
25% &#x2014; 40    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=64
24% &#x2014; 3D    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=61
23% &#x2014; 3B    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=59
22% &#x2014; 38    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=56
21% &#x2014; 36    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=54
20% &#x2014; 33    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=51
19% &#x2014; 30    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=48
18% &#x2014; 2E    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=46
17% &#x2014; 2B    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=43
16% &#x2014; 29    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=41
15% &#x2014; 26    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=38
14% &#x2014; 24    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=36
13% &#x2014; 21    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=33
12% &#x2014; 1F    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=31
11% &#x2014; 1C    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=28
10% &#x2014; 1A    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=26
9% &#x2014; 17    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=23
8% &#x2014; 14    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=20
7% &#x2014; 12    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=18
6% &#x2014; 0F    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=15
5% &#x2014; 0D    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=13
4% &#x2014; 0A    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=10
3% &#x2014; 08    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=8
2% &#x2014; 05    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=5
1% &#x2014; 03    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=3
0% &#x2014; 00    &#x4E0D;&#x900F;&#x660E;&#x5EA6;=0
</code></pre>
<h2 id="&#x900F;&#x660E;&#x5EA6;&#x767E;&#x5206;&#x6BD4;&#x8F6C;&#x6362;&#x6210;&#x5341;&#x516D;&#x8FDB;&#x5236;"><a name="&#x900F;&#x660E;&#x5EA6;&#x767E;&#x5206;&#x6BD4;&#x8F6C;&#x6362;&#x6210;&#x5341;&#x516D;&#x8FDB;&#x5236;" class="anchor-navigation-ex-anchor" href="#&#x900F;&#x660E;&#x5EA6;&#x767E;&#x5206;&#x6BD4;&#x8F6C;&#x6362;&#x6210;&#x5341;&#x516D;&#x8FDB;&#x5236;"><i class="fa fa-link" aria-hidden="true"></i></a>4.5. &#x900F;&#x660E;&#x5EA6;&#x767E;&#x5206;&#x6BD4;&#x8F6C;&#x6362;&#x6210;&#x5341;&#x516D;&#x8FDB;&#x5236;</h2>
<pre><code class="lang-text">&#x900F;&#x660E;&#x5EA6;&#x4EE5;0&#x5230;255&#x8868;&#x793A;&#xFF0C;&#x603B;&#x5171;&#x6709;256&#x7EA7;&#xFF0C;&#x900F;&#x660E;&#x662F;0&#xFF0C;&#x4E0D;&#x900F;&#x660E;&#x662F;255&#x3002;
for(float i=100 ;i&gt;=0 ;i-=1){
    float temp = i/100f;
    int alpha =  Math.round(temp * 255); // &#x7528;&#x56DB;&#x820D;&#x4E94;&#x5165;&#x7684;&#x65B9;&#x5F0F;&#x83B7;&#x5F97; 255&#x7EF4;&#x5EA6;&#x7684;&#x767E;&#x5206;&#x6BD4;
    String hex = Integer.toHexString(alpha).toUpperCase();
    if (hex.length() == 1){
        hex = &quot;0&quot; + hex;
    }
    int percent = (int) (temp * 100);
    System.out.println( String.format(&quot;%d%% &#x2014; %s&quot;, percent, hex) );
}
</code></pre>
<h2 id="popupwindow-&#x91CC;&#x89E6;&#x53D1;&#x5F39;&#x7A97;--&#x4E8C;&#x7EA7;&#x5F39;&#x7A97;"><a name="popupwindow-&#x91CC;&#x89E6;&#x53D1;&#x5F39;&#x7A97;--&#x4E8C;&#x7EA7;&#x5F39;&#x7A97;" class="anchor-navigation-ex-anchor" href="#popupwindow-&#x91CC;&#x89E6;&#x53D1;&#x5F39;&#x7A97;--&#x4E8C;&#x7EA7;&#x5F39;&#x7A97;"><i class="fa fa-link" aria-hidden="true"></i></a>4.6. PopupWindow &#x91CC;&#x89E6;&#x53D1;&#x5F39;&#x7A97; , &#x4E8C;&#x7EA7;&#x5F39;&#x7A97;</h2>
<pre><code class="lang-text">&#x5728;popupWindow&#x91CC;&#x9762;&#x518D;&#x5F39;&#x51FA;popupWindow&#x7684;&#x65F6;&#x5019;&#x4F1A;&#x62A5;&#x8FD9;&#x6837;&#x7684;&#x9519;&#x8BEF;
ERROR/AndroidRuntime(888): android.view.WindowManager$BadTokenException: Unable to add window -- token android.view.ViewRoot$W@44ef1b68 is not valid; is your activity running? 

&#x89E3;&#x51B3;&#x65B9;&#x6CD5;1
&#x4E0D;&#x8981;&#x5728;&#x5F53;&#x524D;&#x7684; popupWindow &#x91CC;&#x9762;&#x7EE7;&#x7EED;show&#x4E00;&#x4E2A; popupWindow &#xFF0C;&#x5E94;&#x8BE5;&#x5199;&#x4E00;&#x4E2A;&#x63A5;&#x53E3;&#x56DE;&#x8C03;&#x5230;Activity&#x91CC;&#x9762;&#x8FDB;&#x884C;show&#xFF0C;

&#x89E3;&#x51B3;&#x65B9;&#x6CD5;2
&#x7B2C;&#x4E8C;&#x6B21;&#x5F39;&#x7A97;&#x6539;&#x4E3A; Dialog
</code></pre>
<h2 id="popupwindow-&#x89E6;&#x78B0;&#x5916;&#x8FB9;&#x5173;&#x95ED;"><a name="popupwindow-&#x89E6;&#x78B0;&#x5916;&#x8FB9;&#x5173;&#x95ED;" class="anchor-navigation-ex-anchor" href="#popupwindow-&#x89E6;&#x78B0;&#x5916;&#x8FB9;&#x5173;&#x95ED;"><i class="fa fa-link" aria-hidden="true"></i></a>4.7. PopupWindow &#x89E6;&#x78B0;&#x5916;&#x8FB9;&#x5173;&#x95ED;</h2>
<pre><code class="lang-text">    void setThisOutTouchCancel(final boolean able) { 
        setOutsideTouchable(able);
        setTouchInterceptor(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (!isOutsideTouchable()) {
                    View mView = getContentView();
                    if (null != mView)
                        mView.dispatchTouchEvent(event);
                }
                return isFocusable() &amp;&amp; !isOutsideTouchable();
            }
        });
    }
</code></pre>
<h2 id="popupwindow-&#x83B7;&#x53D6;-showatlocation-&#x7684;-parent"><a name="popupwindow-&#x83B7;&#x53D6;-showatlocation-&#x7684;-parent" class="anchor-navigation-ex-anchor" href="#popupwindow-&#x83B7;&#x53D6;-showatlocation-&#x7684;-parent"><i class="fa fa-link" aria-hidden="true"></i></a>4.8. PopupWindow &#x83B7;&#x53D6; showAtLocation &#x7684; parent</h2>
<pre><code class="lang-text">popupWindow.showAtLocation( getContentView(MainActivity.this),  Gravity.CENTER, 0, 0);
private View getContentView(Activity activity) {
    ViewGroup view = (ViewGroup) activity.getWindow().getDecorView();
    FrameLayout content = view.findViewById(android.R.id.content);
    return content.getChildAt(0);
}
&#x6216;&#x8005;&#x76F4;&#x63A5;&#x6839;&#x636E;id&#x83B7;&#x53D6;&#x5230;&#x4E00;&#x4E2A;&#x5177;&#x4F53;&#x7684;view.
</code></pre>
<h2 id="popupwindow-&#x5185;&#x90E8;&#x8FDB;&#x884C;&#x89C6;&#x56FE;&#x5207;&#x6362;"><a name="popupwindow-&#x5185;&#x90E8;&#x8FDB;&#x884C;&#x89C6;&#x56FE;&#x5207;&#x6362;" class="anchor-navigation-ex-anchor" href="#popupwindow-&#x5185;&#x90E8;&#x8FDB;&#x884C;&#x89C6;&#x56FE;&#x5207;&#x6362;"><i class="fa fa-link" aria-hidden="true"></i></a>4.9. PopupWindow &#x5185;&#x90E8;&#x8FDB;&#x884C;&#x89C6;&#x56FE;&#x5207;&#x6362;</h2>
<pre><code class="lang-text">PopupWindow +  HorizontalScrollView &#x65B9;&#x6848;&#x6765;&#x505A; &#x3002;
scrollView.scrollTo(viewWidth*2, 0); // 
&#x8FD9;&#x79CD;&#x65B9;&#x6848;&#x4E00;&#x822C;&#x4E0D;&#x8981;&#x653E;&#x5F88;&#x591A;&#x7279;&#x522B;&#x590D;&#x6742;&#x7684;&#x5E03;&#x5C40;&#xFF0C;
&#x56E0;&#x4E3A;&#x90A3;&#x4E9B;&#x9875;&#x9762;&#x90FD;&#x662F;&#x4E00;&#x6B21;&#x52A0;&#x8F7D;&#x5230; HorizontalScrollView&#x4E2D;&#x7684; &#x3002;
&#x5177;&#x4F53;&#x53C2;&#x8003;&#x8FD9;&#x4E2A;demo.
https://gitee.com/hnyer/PopuwindowDemo
</code></pre>
<h1 id="sharedpreferences"><a name="sharedpreferences" class="anchor-navigation-ex-anchor" href="#sharedpreferences"><i class="fa fa-link" aria-hidden="true"></i></a>5. SharedPreferences</h1>
<p>&#x4E00;&#x4E9B;&#x7B80;&#x5355;&#x7684;&#x3001;&#x65E0;&#x5B89;&#x5168;&#x98CE;&#x9669;&#x7684;&#x952E;&#x503C;&#x5BF9;&#x6570;&#x636E;&#xFF0C;&#x53EF;&#x4EE5;&#x901A;&#x8FC7; SharedPreferences &#x4FDD;&#x5B58;&#x3002;
SharedPreferences &#x662F;&#x4E00;&#x4E2A;&#x8F7B;&#x91CF;&#x7EA7;&#x7684;xml&#x952E;&#x503C;&#x5BF9;&#x6587;&#x4EF6; &#x3002;</p>
<pre><code class="lang-text">SharedPreferences &#x7684;&#x66FF;&#x4EE3;&#x65B9;&#x6848; &#xFF0C;&#x4F7F;&#x7528;&#x817E;&#x8BAF;&#x7684; MMKV .
https://github.com/Tencent/MMKV
// &#x8BBE;&#x7F6E; &#x7F13;&#x5B58;&#x5931;&#x6548;&#x65F6;&#x95F4;
&#x601D;&#x8DEF;&#x662F; MMKV &#x4FDD;&#x5B58;&#x914D;&#x7F6E;&#x65F6;&#xFF0C;&#x5C06;&#x5F53;&#x524D;&#x65F6;&#x95F4;&#x548C;&#x8981;&#x6709;&#x6548;&#x65F6;&#x957F;&#x4E00;&#x8D77;&#x4FDD;&#x5B58;&#x8FDB;&#x53BB;&#xFF0C; 
&#x53D6;&#x51FA;&#x6765;&#x7684;&#x65F6;&#x5019;&#x5224;&#x65AD;&#x4E00;&#x4E0B;&#xFF0C;&#x662F;&#x5426;&#x8D85;&#x65F6;&#x4E86;&#x3002;
&#x5982;&#x679C;&#x8D85;&#x65F6;&#x4E86;&#x5C31;&#x8FD4;&#x56DE;NULL&#x3002;

&#x6587;&#x4EF6;&#x4FDD;&#x5B58;&#x5728; /data/data/&lt;package name&gt;/shared_prefs &#x4E2D;&#xFF0C;&#x660E;&#x6587;&#x53EF;&#x89C1;&#x3002;
&#x7528;&#x771F;&#x673A;&#x4E2D;&#x7684;&#x6587;&#x4EF6;&#x5939;&#x7BA1;&#x7406;&#x5668;&#x4E00;&#x822C;&#x770B;&#x4E0D;&#x5230;&#xFF0C;&#x53EF;&#x4EE5;&#x7528;&#x8FC7; Androidstudio &#x53BB;&#x770B;&#x3002;

&#x5728; SharedPreferencesImpl.java &#x4E2D;
private void startLoadFromDisk() {
    new Thread(&quot;SharedPreferencesImpl-load&quot;) {
    ...
            loadFromDisk(); // &#x5F00;&#x542F;&#x5B50;&#x7EBF;&#x7A0B;&#x8BFB;&#x53D6;
    }.start();
}
</code></pre>
<h2 id="sharedpreferences--apply-&#x548C;--commit-&#x7684;&#x533A;&#x522B;"><a name="sharedpreferences--apply-&#x548C;--commit-&#x7684;&#x533A;&#x522B;" class="anchor-navigation-ex-anchor" href="#sharedpreferences--apply-&#x548C;--commit-&#x7684;&#x533A;&#x522B;"><i class="fa fa-link" aria-hidden="true"></i></a>5.1. SharedPreferences  apply &#x548C;  commit &#x7684;&#x533A;&#x522B;</h2>
<pre><code class="lang-text">apply()&#xFF1A;&#x63D0;&#x4EA4;&#x540E;&#x540C;&#x6B65;&#x5199;&#x5165;&#x5185;&#x5B58;&#xFF0C;&#x7136;&#x540E;&#x5F02;&#x6B65;&#x5199;&#x5165;&#x78C1;&#x76D8;&#xFF0C;&#x6CA1;&#x6709;&#x8FD4;&#x56DE;&#x503C;&#x3002;
commit()&#xFF1A;&#x9700;&#x8981;&#x7B49;&#x5F02;&#x6B65;&#x56DE;&#x5199;&#x78C1;&#x76D8;&#x5B8C;&#x6210;&#x540E;&#x624D;&#x8FD4;&#x56DE;&#xFF0C;&#x6709;&#x8FD4;&#x56DE;&#x503C;&#x3002;
&#x5982;&#x679C;&#x9891;&#x7E41;&#x64CD;&#x4F5C;&#x7684;&#x8BDD; apply &#x7684;&#x6027;&#x80FD;&#x4F1A;&#x4F18;&#x4E8E; commit &#x3002;
</code></pre>
<h2 id="sharedpreferences---&#x662F;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;&#x7684;&#x5417;"><a name="sharedpreferences---&#x662F;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;&#x7684;&#x5417;" class="anchor-navigation-ex-anchor" href="#sharedpreferences---&#x662F;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;&#x7684;&#x5417;"><i class="fa fa-link" aria-hidden="true"></i></a>5.2. SharedPreferences   &#x662F;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;&#x7684;&#x5417;</h2>
<pre><code class="lang-text">SharedPreferences &#x662F;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;&#x7684;&#xFF0C;&#x56E0;&#x4E3A;&#x5185;&#x90E8;&#x6709; synchronized &#x5173;&#x952E;&#x5B57;&#x4FDD;&#x969C;&#x3002;
</code></pre>
<h2 id="sharedpreferences-&#x662F;&#x8FDB;&#x7A0B;&#x5B89;&#x5168;&#x7684;&#x5417;&#xFF1F;-&#x5982;&#x4F55;&#x4FDD;&#x8BC1;&#x8FDB;&#x7A0B;&#x5B89;&#x5168;"><a name="sharedpreferences-&#x662F;&#x8FDB;&#x7A0B;&#x5B89;&#x5168;&#x7684;&#x5417;&#xFF1F;-&#x5982;&#x4F55;&#x4FDD;&#x8BC1;&#x8FDB;&#x7A0B;&#x5B89;&#x5168;" class="anchor-navigation-ex-anchor" href="#sharedpreferences-&#x662F;&#x8FDB;&#x7A0B;&#x5B89;&#x5168;&#x7684;&#x5417;&#xFF1F;-&#x5982;&#x4F55;&#x4FDD;&#x8BC1;&#x8FDB;&#x7A0B;&#x5B89;&#x5168;"><i class="fa fa-link" aria-hidden="true"></i></a>5.3. SharedPreferences &#x662F;&#x8FDB;&#x7A0B;&#x5B89;&#x5168;&#x7684;&#x5417;&#xFF1F; &#x5982;&#x4F55;&#x4FDD;&#x8BC1;&#x8FDB;&#x7A0B;&#x5B89;&#x5168;</h2>
<pre><code class="lang-text">&#x56E0;&#x4E3A; SharedPreferences &#x4F1A;&#x4ECE;&#x5185;&#x5B58;&#x53D6;&#x503C;&#xFF0C;&#x4F46;&#x662F;&#x8FDB;&#x7A0B;&#x95F4;&#x5185;&#x5B58;&#x4E0D;&#x662F;&#x5171;&#x4EAB;&#x7684;&#xFF0C;&#x6240;&#x4EE5;&#x4E0D;&#x662F;&#x591A;&#x8FDB;&#x7A0B;&#x5B89;&#x5168;&#x7684;&#x3002;
// SharedPreferencesImpl.java
public String getString(String key, @Nullable String defValue) {
    synchronized (mLock) {
        awaitLoadedLocked();
        String v = (String)mMap.get(key); // &#x4ECE;&#x5185;&#x5B58;&#x53D6;&#x503C;
        return v != null ? v : defValue;
    }
}

SharedPreferences sharedPreferences =
context.getSharedPreferences(&quot;xxxName&quot;, Context.MODE_MULTI_PROCESS);
// &#x56E0;&#x4E3A;&#x5BF9;&#x591A;&#x8FDB;&#x7A0B;&#x652F;&#x6301;&#x4E0D;&#x5B8C;&#x5584;&#xFF0C;MODE_MULTI_PROCESS (&#x4E5F;&#x4E0D;&#x53EF;&#x9760;) &#x6A21;&#x5F0F;&#x4E5F;&#x5DF2;&#x7ECF;&#x88AB;&#x5E9F;&#x5F03;&#xFF0C;
//  &#x5B98;&#x65B9;&#x63A8;&#x8350; ContentProvider &#x6216;&#x8005; &#x7B2C;&#x4E09;&#x65B9;&#x6846;&#x67B6; MMKV
</code></pre>
<h1 id="alertdialog-&#x6309;&#x94AE;&#x5927;&#x5C0F;&#x95EE;&#x9898;"><a name="alertdialog-&#x6309;&#x94AE;&#x5927;&#x5C0F;&#x95EE;&#x9898;" class="anchor-navigation-ex-anchor" href="#alertdialog-&#x6309;&#x94AE;&#x5927;&#x5C0F;&#x95EE;&#x9898;"><i class="fa fa-link" aria-hidden="true"></i></a>6. AlertDialog &#x6309;&#x94AE;&#x5927;&#x5C0F;&#x95EE;&#x9898;</h1>
<pre><code class="lang-text">TextView textView =new TextView(this);
textView.setText(&quot;Hello TextView&quot;);

AlertDialog dialog =new AlertDialog.Builder(this)
        .setTitle(&quot;Hello aivin&quot;)
        .setView(textView)
        .setPositiveButton(&quot;ok_Btn&quot;, null )
        .show() ;
Button btn = dialog.getButton(AlertDialog.BUTTON_POSITIVE) ;
btn.setAllCaps(false); // &#x91CD;&#x65B0;&#x8BBE;&#x7F6E;
</code></pre>
<h1 id="dialog-&#x5168;&#x5C4F;&#x663E;&#x793A;"><a name="dialog-&#x5168;&#x5C4F;&#x663E;&#x793A;" class="anchor-navigation-ex-anchor" href="#dialog-&#x5168;&#x5C4F;&#x663E;&#x793A;"><i class="fa fa-link" aria-hidden="true"></i></a>7. Dialog &#x5168;&#x5C4F;&#x663E;&#x793A;</h1>
<pre><code class="lang-text">public class LoadingDialogUtils {
    public static Dialog getLoadingDialogInstance(Context context) {
        // &#x6839;&#x636E;&#x6837;&#x5F0F;&#x521B;&#x5EFA; Dialog
        Dialog loadingDialog = new Dialog(context, R.style.iosloading_dialog);
        loadingDialog.setCancelable(false);
        // &#x8BBE;&#x7F6E;&#x81EA;&#x5B9A;&#x4E49;&#x5E03;&#x5C40;
        LayoutInflater inflater = LayoutInflater.from(context);
        View v = inflater.inflate(R.layout.wk_loading_dialog, null);
        LinearLayout layout = v.findViewById(R.id.dialog_view);
        int width = MyDeviceInforHelper.getWidth((Activity) context);
        int height = MyDeviceInforHelper.getRealHeight( (Activity) context) ;
        ViewGroup.LayoutParams layoutParams = new  ViewGroup.LayoutParams(  width   , height);
        loadingDialog.setContentView(layout, layoutParams );
        layout.setBackgroundColor(Color.parseColor(&quot;#80000000&quot;));// &#x8BBE;&#x7F6E;&#x81EA;&#x5B9A;&#x4E49;&#x80CC;&#x666F;&#x989C;&#x8272;
        loadingDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));// &#x8BBE;&#x7F6E;window&#x80CC;&#x666F;
        loadingDialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        return loadingDialog;
    }
}

&lt;style name=&quot;iosloading_dialog&quot; parent=&quot;android:Theme.Dialog&quot;&gt;
    &lt;item name=&quot;android:windowFrame&quot;&gt;@null&lt;/item&gt;
    &lt;item name=&quot;android:windowBackground&quot;&gt;@android:color/transparent&lt;/item&gt;
    &lt;item name=&quot;android:windowNoTitle&quot;&gt;true&lt;/item&gt;
    &lt;item name=&quot;android:windowIsTranslucent&quot;&gt;true&lt;/item&gt;
    &lt;item name=&quot;android:windowIsFloating&quot;&gt;true&lt;/item&gt;
    &lt;item name=&quot;android:windowContentOverlay&quot;&gt;@null&lt;/item&gt;
    &lt;item name=&quot;android:backgroundDimEnabled&quot;&gt;false&lt;/item&gt;
    &lt;item  name= &quot;android:windowFullscreen&quot; &gt;true &lt;/item&gt;
&lt;/style&gt;

public static int getRealHeight(Activity mActivity) {
    mActivity.getWindowManager().getDefaultDisplay().getRealMetrics(myGetDisplayMetrics());
    return  myGetDisplayMetrics().heightPixels;
}
</code></pre>
<h1 id="seekbar"><a name="seekbar" class="anchor-navigation-ex-anchor" href="#seekbar"><i class="fa fa-link" aria-hidden="true"></i></a>8. SeekBar</h1>
<h2 id="seekbar-&#x8FDB;&#x5EA6;&#x6761;&#x663E;&#x793A;&#x4E0D;&#x5168;&#x3001;&#x663E;&#x793A;&#x4E0D;&#x9876;&#x683C;&#x7684;&#x95EE;&#x9898;"><a name="seekbar-&#x8FDB;&#x5EA6;&#x6761;&#x663E;&#x793A;&#x4E0D;&#x5168;&#x3001;&#x663E;&#x793A;&#x4E0D;&#x9876;&#x683C;&#x7684;&#x95EE;&#x9898;" class="anchor-navigation-ex-anchor" href="#seekbar-&#x8FDB;&#x5EA6;&#x6761;&#x663E;&#x793A;&#x4E0D;&#x5168;&#x3001;&#x663E;&#x793A;&#x4E0D;&#x9876;&#x683C;&#x7684;&#x95EE;&#x9898;"><i class="fa fa-link" aria-hidden="true"></i></a>8.1. SeekBar &#x8FDB;&#x5EA6;&#x6761;&#x663E;&#x793A;&#x4E0D;&#x5168;&#x3001;&#x663E;&#x793A;&#x4E0D;&#x9876;&#x683C;&#x7684;&#x95EE;&#x9898;</h2>
<pre><code class="lang-text">&lt;SeekBar
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;wrap_content&quot;
    android:layout_gravity=&quot;center_vertical&quot;
    android:thumbOffset=&quot;0dp&quot; // &#x89E3;&#x51B3;thumb&#x53EA;&#x663E;&#x793A;&#x4E00;&#x534A;&#x7684;&#x95EE;&#x9898;
    android:paddingEnd=&quot;0dp&quot;// &#x89E3;&#x51B3;&#x663E;&#x793A;&#x4E0D;&#x9876;&#x683C;&#x7684;&#x95EE;&#x9898;
    android:paddingStart=&quot;0dp&quot;
    android:maxHeight=&quot;1.5dp&quot;
    android:minHeight=&quot;1.5dp&quot;
    android:progressDrawable=&quot;@drawable/seek_progress&quot;
    android:thumb=&quot;@drawable/seek_thumb&quot; /&gt;
</code></pre>
<h2 id="&#x70B9;&#x51FB;&#x6216;&#x62D6;&#x52A8;&#x7684;&#x5206;&#x6BB5;&#x8FDB;&#x5EA6;&#x6761;"><a name="&#x70B9;&#x51FB;&#x6216;&#x62D6;&#x52A8;&#x7684;&#x5206;&#x6BB5;&#x8FDB;&#x5EA6;&#x6761;" class="anchor-navigation-ex-anchor" href="#&#x70B9;&#x51FB;&#x6216;&#x62D6;&#x52A8;&#x7684;&#x5206;&#x6BB5;&#x8FDB;&#x5EA6;&#x6761;"><i class="fa fa-link" aria-hidden="true"></i></a>8.2. &#x70B9;&#x51FB;&#x6216;&#x62D6;&#x52A8;&#x7684;&#x5206;&#x6BB5;&#x8FDB;&#x5EA6;&#x6761;</h2>
<pre><code class="lang-text">https://gitee.com/Aivin_CodeShare/android_tool_code/raw/master/WkProgressView.java
</code></pre>
<p><img src="../pics/&#x5206;&#x6BB5;&#x8FDB;&#x5EA6;&#x6761;.gif" alt=""></p>
<h2 id="clipdrawable-&#x5B9E;&#x73B0;&#x56FE;&#x7247;&#x8FDB;&#x5EA6;&#x6761;-&#x6548;&#x679C;"><a name="clipdrawable-&#x5B9E;&#x73B0;&#x56FE;&#x7247;&#x8FDB;&#x5EA6;&#x6761;-&#x6548;&#x679C;" class="anchor-navigation-ex-anchor" href="#clipdrawable-&#x5B9E;&#x73B0;&#x56FE;&#x7247;&#x8FDB;&#x5EA6;&#x6761;-&#x6548;&#x679C;"><i class="fa fa-link" aria-hidden="true"></i></a>8.3. ClipDrawable &#x5B9E;&#x73B0;&#x56FE;&#x7247;&#x8FDB;&#x5EA6;&#x6761; &#x6548;&#x679C;</h2>
<pre><code class="lang-text">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;clip xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:drawable=&quot;@mipmap/pic_1&quot;
    android:clipOrientation=&quot;vertical&quot;
    android:gravity=&quot;bottom&quot;&gt;
&lt;/clip&gt;

ImageView imageview =  findViewById(R.id.clipImg);
final ClipDrawable drawable = (ClipDrawable) imageview.getDrawable();
drawable.setLevel( 0);

// 10000 &#x662F;&#x6EE1;&#x7EA7;
int level = (int) (10000 *  i* 0.01);
drawable.setLevel( level);

demo &#x5730;&#x5740; https://gitee.com/Aivin_CodeShare/android_tool_code/raw/master/PicProgressDemo.zip
</code></pre>
<p><img src="../pics/&#x56FE;&#x7247;&#x8FDB;&#x5EA6;&#x6761;.gif" alt=""></p>
<h2 id="&#x52A8;&#x6001;&#x6761;&#x7EB9;&#x80CC;&#x666F;&#x8FDB;&#x5EA6;&#x6761;"><a name="&#x52A8;&#x6001;&#x6761;&#x7EB9;&#x80CC;&#x666F;&#x8FDB;&#x5EA6;&#x6761;" class="anchor-navigation-ex-anchor" href="#&#x52A8;&#x6001;&#x6761;&#x7EB9;&#x80CC;&#x666F;&#x8FDB;&#x5EA6;&#x6761;"><i class="fa fa-link" aria-hidden="true"></i></a>8.4. &#x52A8;&#x6001;&#x6761;&#x7EB9;&#x80CC;&#x666F;&#x8FDB;&#x5EA6;&#x6761;</h2>
<pre><code class="lang-text">&#x65B9;&#x6848;1&#x3001;&#x7B80;&#x5355;&#x4F7F;&#x7528;
&lt;ImageView
   android:layout_width=&quot;90dp&quot;
   android:layout_height=&quot;10dp&quot;
   android:scaleType=&quot;centerCrop&quot;
   // &#x4E00;&#x5F20;&#x9759;&#x6001;&#x7684;&#x6761;&#x7EB9;&#x56FE;&#x7247;
   android:src=&quot;@drawable/pic_cover_blue_white&quot; /&gt;

ViewGroup.LayoutParams lp = mProgressIv.getLayoutParams();
lp.width = (int) (ivWidth* percentFloat); // &#x4E0D;&#x65AD;&#x66F4;&#x6539; imageview&#x7684;&#x957F;&#x5EA6;&#xFF0C;&#x914D;&#x5408; android:scaleType=&quot;centerCrop&quot;
mProgressIv.setLayoutParams(lp);
mProgressIv.postInvalidate();

&#x65B9;&#x6848;2 &#xFF0C;&#x53C2;&#x8003;&#x65E0;&#x9650;&#x5FAA;&#x73AF;&#x7684;&#x6E38;&#x620F;&#x80CC;&#x666F;&#x601D;&#x8DEF;&#xFF0C;&#x7528;&#x4E24;&#x5F20;&#x56FE;&#x7247;&#x4E0D;&#x65AD;&#x5730;&#x52A8;&#x753B;&#x5FAA;&#x73AF;&#x3002;
</code></pre>
<p><img src="../pics/&#x52A8;&#x6001;&#x6761;&#x7EB9;&#x8FDB;&#x5EA6;&#x6761;.gif" alt=""></p>
<h1 id="listview-&#x52A8;&#x6001;&#x6539;&#x53D8;&#x9AD8;&#x5EA6;"><a name="listview-&#x52A8;&#x6001;&#x6539;&#x53D8;&#x9AD8;&#x5EA6;" class="anchor-navigation-ex-anchor" href="#listview-&#x52A8;&#x6001;&#x6539;&#x53D8;&#x9AD8;&#x5EA6;"><i class="fa fa-link" aria-hidden="true"></i></a>9. ListView &#x52A8;&#x6001;&#x6539;&#x53D8;&#x9AD8;&#x5EA6;</h1>
<pre><code class="lang-text"> public void setListViewHeightBasedOnChildren2(ListView listView) {
     ListAdapter listAdapter = listView.getAdapter();
     if (listAdapter == null) {
         return;
     }
     int totalHeight = 0;
     for (int i = 0; i &lt; listAdapter.getCount(); i++) {
         View listItem = listAdapter.getView(i, null, listView);
         // &#x5BF9; &#x5B50;View item &#x4E0D;&#x505A;&#x9650;&#x5236;&#xFF0C;&#x8981;&#x591A;&#x5927;&#x5C31;&#x62A5;&#x4E0A;&#x6765;&#x591A;&#x5927;
         listItem.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
         totalHeight += listItem.getMeasuredHeight();
     }

     ViewGroup.LayoutParams params = listView.getLayoutParams();
     params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() -1));
     listView.setLayoutParams(params);
 }
</code></pre>
<h1 id="&#x7EA6;&#x675F;&#x5E03;&#x5C40;-constraintlayout"><a name="&#x7EA6;&#x675F;&#x5E03;&#x5C40;-constraintlayout" class="anchor-navigation-ex-anchor" href="#&#x7EA6;&#x675F;&#x5E03;&#x5C40;-constraintlayout"><i class="fa fa-link" aria-hidden="true"></i></a>10. &#x7EA6;&#x675F;&#x5E03;&#x5C40; ConstraintLayout</h1>
<p>ConstraintLayout &#x662F;&#x4E00;&#x4E2A;ViewGroup&#xFF0C;&#x53EF;&#x4EE5;&#x5728; Api9 &#x4EE5;&#x4E0A;&#x7684;Android&#x7CFB;&#x7EDF;&#x4F7F;&#x7528;&#x5B83;&#xFF0C;&#x5B83;&#x7684;&#x51FA;&#x73B0;&#x4E3B;&#x8981;&#x662F;&#x4E3A;&#x4E86;&#x89E3;&#x51B3;&#x5E03;&#x5C40;&#x5D4C;&#x5957;&#x8FC7;&#x591A;&#x7684;&#x95EE;&#x9898;&#x3002;
&#x5728;&#x5F00;&#x53D1;&#x8FC7;&#x7A0B;&#x4E2D;&#x7ECF;&#x5E38;&#x80FD;&#x9047;&#x5230;&#x4E00;&#x4E9B;&#x590D;&#x6742;&#x7684;UI&#xFF0C;&#x53EF;&#x80FD;&#x4F1A;&#x51FA;&#x73B0;&#x5E03;&#x5C40;&#x5D4C;&#x5957;&#x8FC7;&#x591A;&#x7684;&#x95EE;&#x9898;&#xFF0C;ConstraintLayout &#x4F7F;&#x7528;&#x8D77;&#x6765;&#x6BD4; RelativeLayout &#x66F4;&#x7075;&#x6D3B;&#x3002;</p>
<pre><code class="lang-text">api &apos;androidx.constraintlayout:constraintlayout:2.0.2&apos;

&lt;Button
    android:layout_width=&quot;wrap_content&quot;
    android:layout_height=&quot;wrap_content&quot;
    app:layout_constraintLeft_toLeftOf=&quot;parent&quot;
    app:layout_constraintRight_toRightOf=&quot;parent&quot;
    app:layout_constraintTop_toTopOf=&quot;parent&quot;
    app:layout_constraintBottom_toBottomOf=&quot;parent&quot; /&gt;

// &#x89D2;&#x5EA6;&#x7EA6;&#x675F; (&#x7248;&#x672C;1.1&#x4E2D;&#x52A0;&#x5165;)
&#x4E00;&#x4E2A;&#x63A7;&#x4EF6;&#x5728;&#x67D0;&#x4E2A;&#x63A7;&#x4EF6;&#x7684;&#x67D0;&#x4E2A;&#x89D2;&#x5EA6;&#x7684;&#x4F4D;&#x7F6E;&#xFF0C;&#x901A;&#x8FC7;&#x5176;&#x4ED6;&#x7684;&#x5E03;&#x5C40;&#x5176;&#x5B9E;&#x662F;&#x4E0D;&#x592A;&#x597D;&#x5B9E;&#x73B0;&#x7684;&#xFF0C;
&#x4F46;&#x662F; ConstraintLayout &#x63D0;&#x4F9B;&#x4E86;&#x89D2;&#x5EA6;&#x4F4D;&#x7F6E;&#x76F8;&#x5173;&#x7684;&#x5C5E;&#x6027;
app:layout_constraintCircle=&quot;&quot;         &#x76EE;&#x6807;&#x63A7;&#x4EF6;id
app:layout_constraintCircleAngle=&quot;&quot;    &#x5BF9;&#x4E8E;&#x76EE;&#x6807;&#x7684;&#x89D2;&#x5EA6;(0-360)
app:layout_constraintCircleRadius=&quot;&quot;   &#x5230;&#x76EE;&#x6807;&#x4E2D;&#x5FC3;&#x7684;&#x8DDD;&#x79BB;

// &#x767E;&#x5206;&#x6BD4;&#x504F;&#x79FB;
&#x8BA9;&#x63A7;&#x4EF6;&#x5728;&#x7236;&#x5E03;&#x5C40;&#x7684;&#x6C34;&#x5E73;&#x65B9;&#x5411;&#x6216;&#x5782;&#x76F4;&#x65B9;&#x5411;&#x7684;&#x767E;&#x5206;&#x4E4B;&#x591A;&#x5C11;&#x7684;&#x4F4D;&#x7F6E;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5982;&#x4E0B;&#x5C5E;&#x6027;&#xFF1A;
app:layout_constraintHorizontal_bias=&quot;&quot;   &#x6C34;&#x5E73;&#x504F;&#x79FB; &#x53D6;&#x503C;&#x8303;&#x56F4;&#x662F;0-1&#x7684;&#x5C0F;&#x6570;
app:layout_constraintVertical_bias=&quot;&quot;     &#x5782;&#x76F4;&#x504F;&#x79FB; &#x53D6;&#x503C;&#x8303;&#x56F4;&#x662F;0-1&#x7684;&#x5C0F;&#x6570;

// A&#x4F9D;&#x8D56;B &#xFF0C;B&#x88AB;Gone&#x65F6;&#xFF0C;A&#x8DDD;&#x79BB;&#x7236;&#x63A7;&#x4EF6;&#x7684;&#x8DDD;&#x79BB;&#x3002;
app:layout_goneMarginBottom=&quot;0dp&quot;
app:layout_goneMarginEnd=&quot;0dp&quot;
app:layout_goneMarginLeft=&quot;0dp&quot;
app:layout_goneMarginRight=&quot;0dp&quot;
app:layout_goneMarginStart=&quot;0dp&quot;
app:layout_goneMarginTop=&quot;0dp&quot;

//&#x8BBE;&#x7F6E;&#x5BBD;&#x9AD8;&#x6BD4;&#x4F8B;
&#x7ED9;&#x5BBD;&#x6216;&#x8005;&#x9AD8;&#x5176;&#x4E2D;&#x4E00;&#x4E2A;&#x8BBE;&#x7F6E;&#x4E3A;0dp&#xFF0C;&#x7136;&#x540E;&#x8BBE;&#x7F6E;&#x8BE5;&#x5C5E;&#x6027;&#x662F;&#x4E00;&#x4E2A;&#x6BD4;&#x4F8B;&#xFF0C;&#x5BBD;&#x548C;&#x9AD8;&#x7684;&#x6BD4;
layout_constraintDimensionRatio

// Chain &#x94FE;
Chain &#x94FE;&#x662F;&#x4E00;&#x79CD;&#x7279;&#x6B8A;&#x7684;&#x7EA6;&#x675F;&#x8BA9;&#x591A;&#x4E2A; chain &#x94FE;&#x8FDE;&#x63A5;&#x7684; Views &#x80FD;&#x591F;&#x5E73;&#x5206;&#x5269;&#x4F59;&#x7A7A;&#x95F4;&#x4F4D;&#x7F6E;&#x3002;
&#x6700;&#x76F8;&#x4F3C;&#x7684;&#x5E94;&#x8BE5;&#x662F; LinearLayout &#x4E2D;&#x7684;&#x6743;&#x91CD;&#x6BD4; weight &#xFF0C;
&#x4F46; Chains &#x94FE;&#x80FD;&#x505A;&#x5230;&#x7684;&#x8FDC;&#x8FDC;&#x4E0D;&#x6B62;&#x6743;&#x91CD;&#x6BD4; weight &#x7684;&#x529F;&#x80FD;&#x3002;
Chain &#x94FE;&#x662F;&#x7531;&#x591A;&#x4E2A; Views &#x7EC4;&#x5408;&#x7684;&#xFF0C;&#x6240;&#x4EE5;&#x8981;&#x521B;&#x5EFA;&#x4E00;&#x4E2A; Chain &#x94FE;&#x5C31;&#x9700;&#x8981;&#x5148;&#x9009;&#x62E9;&#x591A;&#x4E2A;&#x60F3;&#x8981;&#x94FE;&#x63A5;&#x5230;&#x4E00;&#x8D77;&#x7684; Views &#xFF0C;
&#x7136;&#x540E;&#x518D;&#x53F3;&#x952E;&#x9009;&#x62E9; &apos;Center Horizontally&apos; &#x6216;&#x8005; &apos;Center Vertically&apos; &#x6765;&#x521B;&#x5EFA;&#x6C34;&#x5E73;&#x94FE;&#x6216;&#x8005;&#x5782;&#x76F4;&#x94FE;&#x3002;
Chain &#x94FE;&#x7684;&#x521B;&#x5EFA;&#x5B9A;&#x4E49;&#x7684;&#x662F; Chain &#x94FE;&#x7EC4;&#x4EF6;&#x4E4B;&#x95F4;&#x7684;&#x95F4;&#x9699;&#x5173;&#x7CFB;&#xFF0C;&#x5E76;&#x4E0D;&#x5F71;&#x54CD;&#x539F;&#x6709;&#x7684;&#x975E;&#x6210;&#x5458;&#x95F4;&#x7684;&#x7EA6;&#x675F;&#x3002;

Chain &#x94FE;&#x6A21;&#x5F0F;&#x4E00;&#x5171;&#x6709;&#x4E09;&#x79CD;&#xFF0C;&#x5206;&#x522B;&#x4E3A;&#xFF1A;spread &#xFF0C;spread_inside &#x548C; packed &#x3002;
1&#x3001;&#x9ED8;&#x8BA4; spread &#x6A21;&#x5F0F;&#xFF1A;
&#x5C06;&#x5E73;&#x5206;&#x95F4;&#x9699;&#x8BA9;&#x591A;&#x4E2A; Views &#x5E03;&#x5C40;&#x5230;&#x5269;&#x4F59;&#x7A7A;&#x95F4;&#x3002;
2&#x3001;spread_inside &#x6A21;&#x5F0F;&#xFF1A;
&#x5B83;&#x5C06;&#x4F1A;&#x628A;&#x4E24;&#x8FB9;&#x6700;&#x8FB9;&#x7F18;&#x7684;&#x4E24;&#x4E2A; View &#x5230;&#x5916;&#x5411;&#x7236;&#x7EC4;&#x4EF6;&#x8FB9;&#x7F18;&#x7684;&#x8DDD;&#x79BB;&#x53BB;&#x9664;&#xFF0C;
&#x7136;&#x540E;&#x8BA9;&#x5269;&#x4F59;&#x7684; Views &#x5728;&#x5269;&#x4F59;&#x7684;&#x7A7A;&#x95F4;&#x5185;&#x5E73;&#x5206;&#x95F4;&#x9699;&#x5E03;&#x5C40;&#x3002;
3&#x3001; packed &#xFF1A;
&#x5B83;&#x5C06;&#x6240;&#x6709; Views &#x6253;&#x5305;&#x5230;&#x4E00;&#x8D77;&#x4E0D;&#x5206;&#x914D;&#x591A;&#x4F59;&#x7684;&#x95F4;&#x9699; &#xFF0C;&#x7136;&#x540E;&#x5C06;&#x6574;&#x4E2A;&#x7EC4;&#x4EF6;&#x7EC4;&#x5728;&#x53EF;&#x7528;&#x7684;&#x5269;&#x4F59;&#x4F4D;&#x7F6E;&#x5C45;&#x4E2D;&#x3002;
</code></pre>
<h2 id="constraintlayout-&#x5E38;&#x7528;&#x5C5E;&#x6027;"><a name="constraintlayout-&#x5E38;&#x7528;&#x5C5E;&#x6027;" class="anchor-navigation-ex-anchor" href="#constraintlayout-&#x5E38;&#x7528;&#x5C5E;&#x6027;"><i class="fa fa-link" aria-hidden="true"></i></a>10.1. ConstraintLayout &#x5E38;&#x7528;&#x5C5E;&#x6027;</h2>
<table>
<thead>
<tr>
<th>&#x5C5E;&#x6027;</th>
<th>&#x610F;&#x4E49;</th>
</tr>
</thead>
<tbody>
<tr>
<td>app:layout_constraintLeft_toLeftOf</td>
<td>&#x6B64;&#x63A7;&#x4EF6;&#x7684;&#x5DE6;&#x8FB9;&#x6846;&#x4E0E;&#x67D0;&#x4E2A;&#x63A7;&#x4EF6;&#x7684;&#x5DE6;&#x8FB9;&#x6846;&#x5BF9;&#x9F50;</td>
</tr>
<tr>
<td>app:layout_constraintLeft_toRightOf</td>
<td>&#x6B64;&#x63A7;&#x4EF6;&#x7684;&#x5DE6;&#x8FB9;&#x6846;&#x4E0E;&#x67D0;&#x4E2A;&#x63A7;&#x4EF6;&#x7684;&#x53F3;&#x8FB9;&#x6846;&#x5BF9;&#x9F50;&#x6216;&#x8005;&#x5728;&#x5176;&#x53F3;&#x8FB9;</td>
</tr>
<tr>
<td>app:layout_constraintRight_toLeftOf</td>
<td>&#x6B64;&#x63A7;&#x4EF6;&#x7684;&#x53F3;&#x8FB9;&#x6846;&#x4E0E;&#x67D0;&#x4E2A;&#x63A7;&#x4EF6;&#x7684;&#x5DE6;&#x8FB9;&#x6846;&#x5BF9;&#x9F50;&#x6216;&#x5728;&#x5176;&#x5DE6;&#x8FB9;</td>
</tr>
<tr>
<td>app:layout_constraintRight_toRightOf</td>
<td>&#x6B64;&#x63A7;&#x4EF6;&#x7684;&#x53F3;&#x8FB9;&#x6846;&#x4E0E;&#x67D0;&#x4E2A;&#x63A7;&#x4EF6;&#x7684;&#x53F3;&#x8FB9;&#x6846;&#x5BF9;&#x9F50;</td>
</tr>
<tr>
<td>app:layout_constraintTop_toTopOf</td>
<td>&#x6B64;&#x63A7;&#x4EF6;&#x7684;&#x9876;&#x90E8;&#x8FB9;&#x6846;&#x4E0E;&#x67D0;&#x4E2A;&#x63A7;&#x4EF6;&#x7684;&#x9876;&#x90E8;&#x8FB9;&#x6846;&#x6C34;&#x5E73;&#x5BF9;&#x9F50;</td>
</tr>
<tr>
<td>layout_constraintTop_toBottomOf</td>
<td>&#x6B64;&#x63A7;&#x4EF6;&#x7684;&#x9876;&#x90E8;&#x8FB9;&#x6846;&#x4E0E;&#x67D0;&#x4E2A;&#x63A7;&#x4EF6;&#x7684;&#x5E95;&#x90E8;&#x8FB9;&#x6846;&#x6C34;&#x5E73;&#x5BF9;&#x9F50;&#x6216;&#x5728;&#x5176;&#x4E0B;&#x8FB9;</td>
</tr>
<tr>
<td>app:layout_constraintBottom_toTopOf</td>
<td>&#x6B64;&#x63A7;&#x4EF6;&#x7684;&#x5E95;&#x90E8;&#x8FB9;&#x6846;&#x4E0E;&#x67D0;&#x4E2A;&#x63A7;&#x4EF6;&#x7684;&#x9876;&#x90E8;&#x8FB9;&#x6846;&#x6C34;&#x5E73;&#x5BF9;&#x9F50;&#x6216;&#x5176;&#x4E0A;&#x8FB9;</td>
</tr>
<tr>
<td>app:layout_constraintBottom_toBottomOf</td>
<td>&#x6B64;&#x63A7;&#x4EF6;&#x7684;&#x5E95;&#x90E8;&#x8FB9;&#x6846;&#x4E0E;&#x67D0;&#x4E2A;&#x63A7;&#x4EF6;&#x7684;&#x5E95;&#x90E8;&#x8FB9;&#x6846;&#x6C34;&#x5E73;&#x5BF9;&#x9F50;&#x6216;&#x5176;&#x4E0A;&#x8FB9;</td>
</tr>
<tr>
<td>app:layout_constraintBaseline_toBaselineOf</td>
<td>&#x6B64;&#x63A7;&#x4EF6;&#x4E0E;&#x67D0;&#x4E2A;&#x63A7;&#x4EF6;&#x6C34;&#x5E73;&#x5BF9;&#x9F50;</td>
</tr>
<tr>
<td>layout_constraintStart_toEndOf</td>
<td>&#x6B64;&#x63A7;&#x4EF6;&#x7684;&#x5DE6;&#x8FB9;&#x754C;&#x5728;&#x67D0;&#x4E2A;&#x63A7;&#x4EF6;&#x53F3;&#x8FB9;&#x754C;&#x7684;&#x53F3;&#x8FB9;&#xFF0C;&#x53CA;&#x8868;&#x793A;&#x6B64;&#x63A7;&#x4EF6;&#x5728;&#x67D0;&#x4E2A;&#x63A7;&#x4EF6;&#x7684;&#x53F3;&#x8FB9;</td>
</tr>
<tr>
<td>layout_constraintStart_toStartOf</td>
<td>&#x6B64;&#x63A7;&#x4EF6;&#x7684;&#x5DE6;&#x8FB9;&#x754C;&#x4E0E;&#x67D0;&#x4E2A;&#x63A7;&#x4EF6;&#x7684;&#x5DE6;&#x8FB9;&#x754C;&#x5728;&#x540C;&#x4E00;&#x5782;&#x76F4;&#x7EBF;&#x4E0A;</td>
</tr>
<tr>
<td>layout_constraintEnd_toStartOf</td>
<td>&#x6B64;&#x63A7;&#x4EF6;&#x7684;&#x53F3;&#x8FB9;&#x754C;&#x4E0E;&#x67D0;&#x4E2A;&#x63A7;&#x4EF6;&#x7684;&#x5DE6;&#x8FB9;&#x754C;&#x5728;&#x540C;&#x4E00;&#x5782;&#x76F4;&#x7EBF;&#x4E0A;</td>
</tr>
<tr>
<td>layout_constraintEnd_toEndOf</td>
<td>&#x6B64;&#x63A7;&#x4EF6;&#x7684;&#x53F3;&#x8FB9;&#x754C;&#x4E0E;&#x67D0;&#x4E2A;&#x63A7;&#x4EF6;&#x7684;&#x53F3;&#x8FB9;&#x754C;&#x5BF9;&#x9F50;</td>
</tr>
</tbody>
</table>
<footer class="page-footer"><span class="copyright">( no Copyright&#xFF0C;enjoy youself ! ) all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">The file was updated at :
2022-04-04 10:49:02
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="android零散知识.html" class="navigation navigation-prev " aria-label="Previous page: Android部分">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="android零散知识.html" class="navigation navigation-next " aria-label="Next page: Android零散知识">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"基础控件使用","level":"1.12.1","depth":2,"next":{"title":"Android零散知识","level":"1.12.2","depth":2,"path":"chinese/android基础/android零散知识.md","ref":"chinese/android基础/android零散知识.md","articles":[]},"previous":{"title":"Android部分","level":"1.12","depth":1,"path":"chinese/android基础/android零散知识.md","ref":"chinese/android基础/android零散知识.md","articles":[{"title":"基础控件使用","level":"1.12.1","depth":2,"path":"chinese/android基础/基础控件使用.md","ref":"chinese/android基础/基础控件使用.md","articles":[]},{"title":"Android零散知识","level":"1.12.2","depth":2,"path":"chinese/android基础/android零散知识.md","ref":"chinese/android基础/android零散知识.md","articles":[]},{"title":"Android坐标体系","level":"1.12.3","depth":2,"path":"chinese/android基础/android坐标体系.md","ref":"chinese/android基础/android坐标体系.md","articles":[]},{"title":"APP启动流程","level":"1.12.4","depth":2,"path":"chinese/android基础/APP的启动流程.md","ref":"chinese/android基础/APP的启动流程.md","articles":[]},{"title":"View加载流程","level":"1.12.5","depth":2,"path":"chinese/android基础/View加载流程.md","ref":"chinese/android基础/View加载流程.md","articles":[]},{"title":"事件分发机制","level":"1.12.6","depth":2,"path":"chinese/android基础/事件分发机制.md","ref":"chinese/android基础/事件分发机制.md","articles":[]},{"title":"控件绘制流程","level":"1.12.7","depth":2,"path":"chinese/android基础/控件绘制流程.md","ref":"chinese/android基础/控件绘制流程.md","articles":[]},{"title":"常用shape","level":"1.12.8","depth":2,"path":"chinese/android基础/常用shape.md","ref":"chinese/android基础/常用shape.md","articles":[]},{"title":"进程通信","level":"1.12.9","depth":2,"path":"chinese/android基础/进程通信.md","ref":"chinese/android基础/进程通信.md","articles":[]},{"title":"通信方式详解","level":"1.12.10","depth":2,"path":"chinese/通信方式/通信方式详解.md","ref":"chinese/通信方式/通信方式详解.md","articles":[]},{"title":"Binder详解","level":"1.12.11","depth":2,"path":"chinese/android基础/Binder详解.md","ref":"chinese/android基础/Binder详解.md","articles":[]},{"title":"Handle详解","level":"1.12.12","depth":2,"path":"chinese/android基础/Handler详解.md","ref":"chinese/android基础/Handler详解.md","articles":[]},{"title":"Fragment详解","level":"1.12.13","depth":2,"path":"chinese/android基础/Fragment详解.md","ref":"chinese/android基础/Fragment详解.md","articles":[]},{"title":"Activity详解","level":"1.12.14","depth":2,"path":"chinese/android基础/Activity详解.md","ref":"chinese/android基础/Activity详解.md","articles":[]},{"title":"BroadcastReceiver详解","level":"1.12.15","depth":2,"path":"chinese/android基础/BroadcastReceiver.md","ref":"chinese/android基础/BroadcastReceiver.md","articles":[]},{"title":"Service详解","level":"1.12.16","depth":2,"path":"chinese/android基础/Service服务.md","ref":"chinese/android基础/Service服务.md","articles":[]},{"title":"动画详解","level":"1.12.17","depth":2,"path":"chinese/android基础/动画详解.md","ref":"chinese/android基础/动画详解.md","articles":[]},{"title":"屏幕刷新机制","level":"1.12.18","depth":2,"path":"chinese/android基础/屏幕刷新机制.md","ref":"chinese/android基础/屏幕刷新机制.md","articles":[]},{"title":"屏幕适配","level":"1.12.19","depth":2,"path":"chinese/android基础/屏幕适配.md","ref":"chinese/android基础/屏幕适配.md","articles":[]},{"title":"图片加载详解","level":"1.12.20","depth":2,"path":"chinese/android基础/图片加载详解.md","ref":"chinese/android基础/图片加载详解.md","articles":[]},{"title":"WebView详解","level":"1.12.21","depth":2,"path":"chinese/android基础/WebView详解.md","ref":"chinese/android基础/WebView详解.md","articles":[]},{"title":"沉浸式","level":"1.12.22","depth":2,"path":"chinese/android基础/沉浸式.md","ref":"chinese/android基础/沉浸式.md","articles":[]},{"title":"相机模块","level":"1.12.23","depth":2,"path":"chinese/android基础/相机模块.md","ref":"chinese/android基础/相机模块.md","articles":[]},{"title":"地图模块","level":"1.12.24","depth":2,"path":"chinese/android基础/地图模块.md","ref":"chinese/android基础/地图模块.md","articles":[]},{"title":"Androidstudio插件开发","level":"1.12.25","depth":2,"path":"chinese/android基础/Androidstudio插件开发.md","ref":"chinese/android基础/Androidstudio插件开发.md","articles":[]},{"title":"Apk插件化开发","level":"1.12.26","depth":2,"path":"chinese/android基础/Apk插件化开发.md","ref":"chinese/android基础/Apk插件化开发.md","articles":[]},{"title":"App组件化开发","level":"1.12.27","depth":2,"path":"chinese/android基础/App组件化开发.md","ref":"chinese/android基础/App组件化开发.md","articles":[]},{"title":"sdk开发","level":"1.12.28","depth":2,"path":"chinese/android基础/sdk开发.md","ref":"chinese/android基础/sdk开发.md","articles":[]},{"title":"APP优化","level":"1.12.29","depth":2,"path":"chinese/android基础/APP优化.md","ref":"chinese/android基础/APP优化.md","articles":[]},{"title":"项目参数配置","level":"1.12.30","depth":2,"path":"chinese/android基础/项目参数配置.md","ref":"chinese/android基础/项目参数配置.md","articles":[]},{"title":"App发布","level":"1.12.31","depth":2,"path":"chinese/android基础/App发布.md","ref":"chinese/android基础/App发布.md","articles":[]},{"title":"Android外挂","level":"1.12.32","depth":2,"path":"chinese/android基础/Android外挂.md","ref":"chinese/android基础/Android外挂.md","articles":[]},{"title":"Android字节码插桩","level":"1.12.33","depth":2,"path":"chinese/android基础/Android字节码插桩.md","ref":"chinese/android基础/Android字节码插桩.md","articles":[]},{"title":"智能家居","level":"1.12.34","depth":2,"path":"chinese/android基础/智能家居.md","ref":"chinese/android基础/智能家居.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["-search","search-plus","todo","anchor-navigation-ex","copy-code-button","fontsettings","tbfed-pagefooter","local-video","splitter","expandable-chapters","favicon","theme-comscore","local-video"],"styles":{"website":"styles/website.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"( no Copyright，enjoy youself ! )","modify_label":"The file was updated at :","modify_format":"YYYY-MM-DD HH:mm:ss"},"todo":{},"splitter":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"family":"sans","size":2,"theme":"white"},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":true},"favicon":{"shortcut":"assets/images/favicon.ico","bookmark":"assets/images/favicon.ico"},"theme-comscore":{},"local-video":{},"copy-code-button":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{},"search-plus":{}},"theme":"default","author":"Aivin","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Aivin开发笔记","language":"zh-hans","gitbook":"*","description":"Aivin开发笔记"},"file":{"path":"chinese/android基础/基础控件使用.md","mtime":"2022-04-04T02:49:02.752Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-04-04T03:47:09.782Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-local-video/video.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

